<template>
  <div class="app-container">
    <Find :OriginalFilter="{ static: true }" :formList="formList1" @findClicked="findData" @Launchform="Launchform3" />

    <el-card style="margin-top: 10px" shadow="always" :body-style="{ padding: '5px' }">
      <div style="display: flex">
        <div style="width: 50%">
          <h1>{{ $t(`Print.TheRemainingMaterialDetailsAre`) }}</h1>
          <Table
            :isLoading="isLoading7"
            @confirmChange="confirmChange1"
            class="table1"
            @currentRow="currentRowList3"
            :tableHeader="tableHeader"
            :tableData="BringOutTheRemainingMaterialDetailsForInquiryMehtodsTableDateList"
            :TableHeight="100"
            :outTableHeight="60"
          />
        </div>
        <div style="width: 60%; margin-left: 10px">
          <h1>{{ $t(`Print.TheRemainingMaterialOutboundDetailsAre`) }}</h1>
          <Table
            :isLoading="isLoading8"
            @currentRow="currentRowList5"
            :tableHeader="tableHeader1"
            :tableData="DetailsOfRemainingMaterialsOutOfStorageMehotdsTableDateList"
            :TableHeight="100"
            :outTableHeight="60"
          />
        </div>
      </div>
      <PageModule :PageData="{ pageSizeShow: true }" />
    </el-card>

    <!-- 库存材料 -->
    <el-drawer v-model="drawer2" :direction="'ttb'" size="small" :with-header="false">
      <span @click="drawer2 = false" style="float: right; cursor: pointer; color: rgb(7, 7, 7)">X</span>
      <h1>{{ $t(`Print.QueryCondition`) }}</h1>
      <Find
        :OriginalFilter="{ static: true }"
        :searchImg="false"
        :formList="formList3"
        @findClicked="findData1"
        @Launchform="Launchform1"
        @clickNumber="clickNumber1"
      />
      <Table
        @currentRow1="currentRowList2"
        :isLoading="isLoading1"
        :tableHeader="tableHeader5"
        :tableData="InventoryMaterialInquiryMethodsParmsTableDateList.dtos"
        :TableHeight="100"
        :outTableHeight="55"
      />
      <PageModule :PageData="{ total }" @pageSizeChange="handleSizeChangeTk" @pageChange="handleCurrentChangeTk" />
    </el-drawer>

    <!-- 指令材料 -->
    <el-drawer v-model="drawer3" :direction="'ttb'" size="small" :with-header="false">
      <h1>{{ $t(`Print.QueryCondition`) }}</h1>
      <Find :OriginalFilter="{ static: true }" :searchImg="false" :formList="formList2" @Launchform="Launchform2" @findClicked="findClicked2" />
      <div style="width: 70%; margin-top: 15px">
        <Table
          @selectList="selectList"
          @currentRow="currentRowList1"
          :isLoading="isLoading2"
          :selection="true"
          :tableHeader="tableHeader6"
          :tableData="CommandMaterialMethodsTableDateList.dtos"
          :TableHeight="40"
          :outTableHeight="55"
        />
        <PageModule :PageData="{ total: totalCommand }" @pageSizeChange="handleSizeChangeCommand" @pageChange="handleCurrentChangeCommand" />
      </div>
      <Table
        :isLoading="isLoading3"
        style="width: 70%"
        :tableHeader="tableHeader7"
        :tableData="QueryTheDetailsOfTheFitSubMateriaMethodsTableDate"
        :TableHeight="40"
        :outTableHeight="55"
      />
    </el-drawer>
  </div>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import { result } from 'lodash'
import LoginWork from '@/utils/LoginWork'
import JMessage from '@/utils/JMessage'
export default defineComponent({
  name: 'TransferLeftoverMaterialsLeave'
})
</script>
<script lang="ts" setup>
import { i18n, Jzhcn } from '@/i18n'
import { classifyQuery } from '@/api/WarehouseDepartment/FactoryStorage/FitOutsourcingProcessing'
import {
  InventoryMaterialInquiry,
  type InventoryMaterialInquiryInterface,
  type InventoryMaterialInquiryParms
} from '@/api/WarehouseDepartment/FactoryStorage/TransferLeftoverMaterialsInto'
import {
  OutboundBatchProcessingAdded,
  DetailsToBeReleasedAreDeleted,
  TheDetailsToBeReleasedAreDeleted,
  DetailsOfRemainingMaterialsToBeDeliveredAreAdded,
  DepartmentInquiry,
  DetailsOfRemainingMaterialsOutOfStorage,
  BringOutTheRemainingMaterialDetailsForInquiry,
  QueryTheDetailsOfTheFitSubMateria,
  CommandMaterial
} from '@/api/WarehouseDepartment/FactoryStorage/TransferLeftoverMaterialsLeave'
import type {
  DetailsOfRemainingMaterialsOutOfStorageInterface,
  DetailsOfRemainingMaterialsOutOfStorageParms,
  QueryTheDetailsOfTheFitSubMateriaInterface,
  CommandMaterialParmsList,
  CommandMaterialInterface
} from '@/api/WarehouseDepartment/FactoryStorage/TransferLeftoverMaterialsLeave'
import { ref, watch, onMounted } from 'vue'
import { ElMessage } from 'element-plus'
import { ElMessageBox } from 'element-plus'
const isLoading7 = ref(false)

const isLoading8 = ref(false)

const formList1 = ref([
  {
    type: 'button',
    checkboxLabel: '库存材料'
  },
  {
    type: 'button',
    checkboxLabel: '指令材料'
  },
  {
    type: 'button',
    checkboxLabel: '贴合子材料'
  },
  {
    type: 'dateSingle',
    dateLabel: '入库日期',
    dateValue: ''
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '部门',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '出库原因',
    selectLabel: '',
    selectOptions: [
      {
        optionKey: 1,
        optionValue: '抵充出库',
        optionLabel: '抵充出库'
      },
      {
        optionKey: 2,
        optionValue: '转大货仓',
        optionLabel: '转大货仓'
      }
    ]
  },
  {
    type: 'button',
    checkboxLabel: '出库批处理'
  },
  {
    type: 'input',
    inputPlaceholder: '请输入出库单号',
    inputValue: ''
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '出库原因 ',
    selectLabel: '',
    selectOptions: [
      {
        optionKey: 1,
        optionValue: '抵充出库',
        optionLabel: '抵充出库'
      },
      {
        optionKey: 2,
        optionValue: '转大货仓',
        optionLabel: '转大货仓'
      }
    ]
  },
  {
    type: 'date',
    dateLabel: '出库日期',
    dateValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '请输入材料名称',
    inputValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '请输入指令',
    inputValue: ''
  },
  {
    type: 'button',
    checkboxLabel: '待出剩料明细删除'
  },
  {
    type: 'button',
    checkboxLabel: '剩料出库明细删除'
  },
  {
    type: 'button',
    checkboxLabel: '置空',
    bgColor: '#1890FF'
  }
])

const formList3 = ref([
  {
    type: 'input',
    inputPlaceholder: '物料编码',
    inputValue: ''
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '分类',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'input',
    inputPlaceholder: '材料名称',
    inputValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '库位',
    inputValue: ''
  },
  {
    type: 'radio',
    checkboxLabel: '全部',
    checked: true,
    label: '1'
  },
  {
    type: 'radio',
    checkboxLabel: '大于0',
    checked: false,
    label: '2'
  },
  {
    type: 'radio',
    checkboxLabel: '等于0',
    checked: false,
    label: '3'
  },
  {
    type: 'button',
    checkboxLabel: '置空',
    bgColor: '#1890FF'
  }
])

const formList2 = ref([
  {
    type: 'input',
    inputPlaceholder: '指令',
    inputValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '型体',
    inputValue: ''
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '分类',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'input',
    inputPlaceholder: '材料名称',
    inputValue: ''
  },
  {
    type: 'button',
    checkboxLabel: '待出批处理'
  },
  {
    type: 'button',
    checkboxLabel: '置空',
    bgColor: '#1890FF'
  }
])

const findData = (count: string) => {
  if (count === '库存材料') {
    InventoryMaterialInquiryMethods()
    drawer2.value = true
    typeListNumber.value = 1
  }
  if (count === '指令材料') {
    CommandMaterialMethods()
    typeList.value = 3
    drawer3.value = true
    typeListNumber.value = 2
  }
  if (count === '贴合子材料') {
    CommandMaterialMethods()
    typeList.value = 4
    drawer3.value = true
    typeListNumber.value = 2
  }
  if (count === '待出剩料明细删除') {
    if (TheDetailsToBeReleasedAreDeletedMehtodsQuery.value === '') {
      JMessage.warning('请选择需要删除的数据')
    } else {
      handleCloseMateriaLKlc1()
    }
  }
  if (count === '剩料出库明细删除') {
    if (DetailsToBeReleasedAreDeletedMehotdsmtlNo.value === '' || DetailsToBeReleasedAreDeletedMehotdsSlipNp.value === '') {
      JMessage.warning('请选择需要删除的数据')
    } else {
      handleCloseMateriaLKlc()
    }
  }
  if (count === '出库批处理') {
    if (
      OutboundBatchProcessingAddedParms.value.slipDate === '' ||
      OutboundBatchProcessingAddedParms.value.deptName === '' ||
      OutboundBatchProcessingAddedParms.value.slipReason === ''
    ) {
      JMessage.warning('请选择需要出库批处理的数据并且日期部门出库原因不可为空')
    } else {
      OutboundBatchProcessingAddedMehotds()
    }
  }
  if (count === '置空') {
    clearFormList()
  }
}

const clearFormList = () => {
  formList1.value.forEach((item) => {
    if (item.type === 'input') {
      item.inputValue = ''
    }
    if (item.type === 'select') {
      item.selectValue = ''
    }
    if (item.type === 'date') {
      item.dateValue = ''
    }
  })
}

const EvaluatesTheArrayReturnValue = (ArrayList: any) => {
  return ArrayList.map((item: any, index: any) => {
    return {
      optionKey: index,
      optionValue: item,
      optionLabel: item
    }
  })
}

const handleCloseMateriaLKlc = (_done?: () => void) => {
  ElMessageBox.confirm('确定要删除该数据吗')
    .then(async () => {
      DetailsToBeReleasedAreDeletedMehotds()
    })
    .catch(() => {})
}

const handleCloseMateriaLKlc1 = (_done?: () => void) => {
  ElMessageBox.confirm('确定要删除该数据吗')
    .then(async () => {
      TheDetailsToBeReleasedAreDeletedMehtods()
    })
    .catch(() => {})
}

// 出库批处理
const OutboundBatchProcessingAddedParms = ref({
  deptName: '',
  deptNo: '',
  slipDate: '',
  slipReason: ''
})

const OutboundBatchProcessingAddedMehotds = async () => {
  const result = await OutboundBatchProcessingAdded(OutboundBatchProcessingAddedParms.value)
  if (result.code === 200) {
    DetailsOfRemainingMaterialsOutOfStorageMehotds()
    BringOutTheRemainingMaterialDetailsForInquiryMehtods()
    JMessage.success(result.message)
  } else {
    DetailsOfRemainingMaterialsOutOfStorageMehotds()
    BringOutTheRemainingMaterialDetailsForInquiryMehtods()
    JMessage.error(result.message)
  }
}

// 待入剩料明细修改
const confirmChange1 = async (row: any) => {
  row.remark === null ? (row.remark = '') : row.remark
  const result = await LoginWork.post<any, any>(`	/pcFactorStockQuery/mOSTempUpdate?mtlNo=${row.mtlNo}&qty=${row.qty}&remark=${row.remark}`)
  if (result.code === 200) {
    BringOutTheRemainingMaterialDetailsForInquiryMehtods()
    JMessage.success(result.message)
  } else {
    BringOutTheRemainingMaterialDetailsForInquiryMehtods()
    JMessage.error(result.message)
  }
}

// 出库明细删除
const currentRowList5 = (row: any) => {
  const { slipNo, mtlNo } = row
  DetailsToBeReleasedAreDeletedMehotdsmtlNo.value = mtlNo
  DetailsToBeReleasedAreDeletedMehotdsSlipNp.value = slipNo
}

const DetailsToBeReleasedAreDeletedMehotdsmtlNo = ref<string>('')
const DetailsToBeReleasedAreDeletedMehotdsSlipNp = ref<string>('')

const DetailsToBeReleasedAreDeletedMehotds = async () => {
  const result = await DetailsToBeReleasedAreDeleted(
    DetailsToBeReleasedAreDeletedMehotdsmtlNo.value,
    DetailsToBeReleasedAreDeletedMehotdsSlipNp.value
  )
  if (result.code === 200) {
    DetailsToBeReleasedAreDeletedMehotdsmtlNo.value = ''
    DetailsToBeReleasedAreDeletedMehotdsSlipNp.value = ''
    DetailsOfRemainingMaterialsOutOfStorageMehotds()
    JMessage.success(result.message)
  } else {
    DetailsToBeReleasedAreDeletedMehotdsmtlNo.value = ''
    DetailsToBeReleasedAreDeletedMehotdsSlipNp.value = ''
    DetailsOfRemainingMaterialsOutOfStorageMehotds()
    JMessage.error(result.message)
  }
}

// 待出明细删除
const TheDetailsToBeReleasedAreDeletedMehtodsQuery = ref<string>('')

const TheDetailsToBeReleasedAreDeletedMehtods = async () => {
  const reuslt = await TheDetailsToBeReleasedAreDeleted(TheDetailsToBeReleasedAreDeletedMehtodsQuery.value)
  if (reuslt.code === 200) {
    TheDetailsToBeReleasedAreDeletedMehtodsQuery.value = ''
    BringOutTheRemainingMaterialDetailsForInquiryMehtods()
    JMessage.success(reuslt.message)
  } else {
    TheDetailsToBeReleasedAreDeletedMehtodsQuery.value = ''
    BringOutTheRemainingMaterialDetailsForInquiryMehtods()
    JMessage.error(reuslt.message)
  }
}

const currentRowList3 = (row: any) => {
  const { mtlNo } = row
  TheDetailsToBeReleasedAreDeletedMehtodsQuery.value = mtlNo
}

// 指令材料 -> 贴合子材料新增
const selectList = (row: any) => {
  DetailsOfRemainingMaterialsToBeDeliveredAreAddedMehtodsParms.value = row.map((item: any) => {
    return item
  })
}

// 材料库新增
const currentRowList2 = (row: any) => {
  row.color = row.mtlColor
  DetailsOfRemainingMaterialsToBeDeliveredAreAddedMehtodsParms.value.push(row)
  DetailsOfRemainingMaterialsToBeDeliveredAreAddedMehtods()
}

// 待出剩料明细新增
const typeListNumber = ref(-1)

const DetailsOfRemainingMaterialsToBeDeliveredAreAddedMehtodsParms = ref<any>([])

const DetailsOfRemainingMaterialsToBeDeliveredAreAddedMehtods = async () => {
  const result = await DetailsOfRemainingMaterialsToBeDeliveredAreAdded(
    typeListNumber.value,
    DetailsOfRemainingMaterialsToBeDeliveredAreAddedMehtodsParms.value
  )
  if (result.code === 200) {
    BringOutTheRemainingMaterialDetailsForInquiryMehtods()
    CommandMaterialMethods()
    DetailsOfRemainingMaterialsToBeDeliveredAreAddedMehtodsParms.value = []
    JMessage.success(result.message)
  } else {
    DetailsOfRemainingMaterialsToBeDeliveredAreAddedMehtodsParms.value = []
    CommandMaterialMethods()
    BringOutTheRemainingMaterialDetailsForInquiryMehtods()
    JMessage.error(result.message)
  }
}

// 部门查询
const DepartmentInquiryMedhos = async () => {
  let NewArray = []
  const result = await DepartmentInquiry()
  NewArray = result.reduce((arr: any, item: any) => {
    if (item.deptName && item.deptNo) {
      // 只添加非空的 typeName 和 typeNo
      arr.push(item.deptNo + ' ' + item.deptName)
    }
    return arr
  }, [])
  formList1.value[4].selectOptions = EvaluatesTheArrayReturnValue(NewArray)
}

// 剩料出库明细
const Launchform3 = (row: any) => {
  DetailsOfRemainingMaterialsOutOfStorageMehotdsParms.value.slipNo = row[7].inputValue
  DetailsOfRemainingMaterialsOutOfStorageMehotdsParms.value.slipReason = row[8].selectValue
  DetailsOfRemainingMaterialsOutOfStorageMehotdsParms.value.slipDateStart = row[9].dateValue[0]
  DetailsOfRemainingMaterialsOutOfStorageMehotdsParms.value.slipDateEnd = row[9].dateValue[1]
  DetailsOfRemainingMaterialsOutOfStorageMehotdsParms.value.mtlName = row[10].inputValue
  DetailsOfRemainingMaterialsOutOfStorageMehotdsParms.value.lotNo = row[11].inputValue
  DetailsOfRemainingMaterialsOutOfStorageMehotds()

  OutboundBatchProcessingAddedParms.value.deptName = row[4].selectValue.split(' ')[1]
  OutboundBatchProcessingAddedParms.value.deptNo = row[4].selectValue.split(' ')[0]
  OutboundBatchProcessingAddedParms.value.slipDate = row[3].dateValue
  OutboundBatchProcessingAddedParms.value.slipReason = row[5].selectValue
}

const DetailsOfRemainingMaterialsOutOfStorageMehotdsParms = ref<DetailsOfRemainingMaterialsOutOfStorageParms>({
  lotNo: '',
  mtlName: '',
  slipDateEnd: '',
  slipDateStart: '',
  slipNo: '',
  slipReason: ''
})

const DetailsOfRemainingMaterialsOutOfStorageMehotdsTableDateList = ref<DetailsOfRemainingMaterialsOutOfStorageInterface[]>([])

const DetailsOfRemainingMaterialsOutOfStorageMehotds = async () => {
  isLoading8.value = true
  const result = await DetailsOfRemainingMaterialsOutOfStorage(DetailsOfRemainingMaterialsOutOfStorageMehotdsParms.value)
  DetailsOfRemainingMaterialsOutOfStorageMehotdsTableDateList.value = result
  isLoading8.value = false
}

// 待出剩料明细查询
const BringOutTheRemainingMaterialDetailsForInquiryMehtodsTableDateList = ref<any>([])

const BringOutTheRemainingMaterialDetailsForInquiryMehtods = async () => {
  isLoading7.value = true
  const result = await BringOutTheRemainingMaterialDetailsForInquiry()
  BringOutTheRemainingMaterialDetailsForInquiryMehtodsTableDateList.value = result.map((item: any) => {
    item.change = true
    return item
  })
  isLoading7.value = false
}

// 贴合子材料明细查询
const currentRowList1 = (row: any) => {
  const { mtlNo } = row
  mtlNo1List.value = mtlNo
  QueryTheDetailsOfTheFitSubMateriaMethods()
}

const isLoading3 = ref(false)

const QueryTheDetailsOfTheFitSubMateriaMethodsTableDate = ref<QueryTheDetailsOfTheFitSubMateriaInterface[]>([])

const mtlNo1List = ref('')

const QueryTheDetailsOfTheFitSubMateriaMethods = async () => {
  isLoading3.value = true
  const result = await QueryTheDetailsOfTheFitSubMateria(mtlNo1List.value)
  QueryTheDetailsOfTheFitSubMateriaMethodsTableDate.value = result.map((item: any) => {
    if (item.purFlag === 'Y') {
      item.purFlag = true
    }
    if (item.percent !== null) {
      item.percent = Number(item.percent).toFixed(0)
    }
    return item
  })
  isLoading3.value = false
}

// 指令材料
const clearFormList1 = () => {
  formList2.value.forEach((item) => {
    if (item.type === 'input') {
      item.inputValue = ''
    }
    if (item.type === 'select') {
      item.selectValue = ''
    }
  })
}

const findClicked2 = (conut: string) => {
  if (conut === '置空') {
    clearFormList1()
  }
  if (conut === '待出批处理') {
    if (DetailsOfRemainingMaterialsToBeDeliveredAreAddedMehtodsParms.value.length === 0) {
      JMessage.warning('请选择需要添加的数据')
    } else {
      DetailsOfRemainingMaterialsToBeDeliveredAreAddedMehtods()
    }
  }
}

const isLoading2 = ref(false)

const Launchform2 = (row: any) => {
  CommandMaterialMethodsParms.value.lotNo = row[0].inputValue
  CommandMaterialMethodsParms.value.style = row[1].inputValue
  CommandMaterialMethodsParms.value.typeNo = row[2].selectValue.split(' ')[0]
  CommandMaterialMethodsParms.value.mtlName = row[3].inputValue
  CommandMaterialMethods()
}

const drawer3 = ref(false)

const CommandMaterialMethodsTableDateList = ref<CommandMaterialInterface>({
  dtos: []
})

const CommandMaterialMethodsParms = ref<CommandMaterialParmsList>({
  lotNo: '',
  mtlName: '',
  pageNum: 1,
  pageSize: 40,
  style: '',
  typeNo: ''
})

const typeList = ref<number>(0)

const CommandMaterialMethods = async () => {
  isLoading2.value = true
  const result = await CommandMaterial(typeList.value, CommandMaterialMethodsParms.value)
  CommandMaterialMethodsTableDateList.value.dtos = result.dtos
  totalCommand.value = result.total!
  if (result.dtos.length > 0) {
    mtlNo1List.value = result.dtos[0].mtlNo
    QueryTheDetailsOfTheFitSubMateriaMethods()
  }
  isLoading2.value = false
}

const totalCommand = ref(0)

const handleSizeChangeCommand = (val: number) => {
  CommandMaterialMethodsParms.value.pageSize = val
  CommandMaterialMethods()
}

const handleCurrentChangeCommand = (val: number) => {
  CommandMaterialMethodsParms.value.pageNum = val
  CommandMaterialMethods()
}

// 库存材料
const isLoading1 = ref(true)

const clearFormList3 = () => {
  formList3.value.forEach((item) => {
    if (item.type === 'input') {
      item.inputValue = ''
    }
    if (item.type === 'select') {
      item.selectValue = ''
    }
  })
}

const findData1 = (count: string) => {
  if (count === '置空') {
    clearFormList3()
  }
}

const classifyQueryMethods = async () => {
  let NewArray = []
  const result = await classifyQuery()
  NewArray = result.reduce((arr: any, item: any) => {
    if (item.typeNo && item.typeName) {
      // 只添加非空的 typeName 和 typeNo
      arr.push(item.typeNo + ' ' + item.typeName)
    }
    return arr
  }, [])
  formList3.value[1].selectOptions = EvaluatesTheArrayReturnValue(NewArray)
  formList2.value[2].selectOptions = EvaluatesTheArrayReturnValue(NewArray)
}

const drawer2 = ref(false)

watch(drawer2, (oldValue, newValue) => {
  if (!drawer2.value) {
    InventoryMaterialInquiryMethodsParmsTableDateList.value.dtos = []
  }
})

const Launchform1 = (row: any) => {
  InventoryMaterialInquiryMethodsParms.value.mtlNo = row[0].inputValue
  InventoryMaterialInquiryMethodsParms.value.mtlName = row[2].inputValue
  InventoryMaterialInquiryMethodsParms.value.mtlType = row[1].selectValue.split(' ')[0]
  InventoryMaterialInquiryMethods()
}

const clickNumber1 = (row: number) => {
  InventoryMaterialInquiryMethodsParms.value.stkFlag = row
  InventoryMaterialInquiryMethods()
}

const total = ref(0)

const handleSizeChangeTk = (val: number) => {
  InventoryMaterialInquiryMethodsParms.value.pageSize = val
  InventoryMaterialInquiryMethods()
}

const handleCurrentChangeTk = (val: number) => {
  InventoryMaterialInquiryMethodsParms.value.pageNum = val
  InventoryMaterialInquiryMethods()
}

const InventoryMaterialInquiryMethodsParms = ref<InventoryMaterialInquiryParms>({
  mtlColor: '',
  mtlName: '',
  mtlNo: '',
  mtlType: '',
  pageNum: 1,
  pageSize: 40,
  stkFlag: 1
})

const InventoryMaterialInquiryMethodsParmsTableDateList = ref<InventoryMaterialInquiryInterface>({
  dtos: []
})

const InventoryMaterialInquiryMethods = async () => {
  isLoading1.value = true
  const result = await InventoryMaterialInquiry(InventoryMaterialInquiryMethodsParms.value)
  InventoryMaterialInquiryMethodsParmsTableDateList.value.dtos = result.dtos
  total.value = result.total!
  isLoading1.value = false
}

onMounted(() => {
  classifyQueryMethods()

  BringOutTheRemainingMaterialDetailsForInquiryMehtods()

  DetailsOfRemainingMaterialsOutOfStorageMehotds()

  DepartmentInquiryMedhos()
})

// 表格数据

const tableHeader = ref([
  {
    label: '指令',
    prop: 'lotNo',
    change: true
  },
  {
    label: '材料颜色',
    prop: 'mtlColor',
    change: true
  },
  {
    label: '材料名称',
    prop: 'mtlName',
    change: true
  },
  {
    label: '规格',
    prop: 'mtlSpec',
    change: true
  },
  {
    label: '单位',
    prop: 'mtlUnit',
    change: true
  },
  {
    label: '数量',
    prop: 'qty'
  },
  {
    label: '备注',
    prop: 'remark'
  }
])

const tableHeader1 = ref([
  {
    label: '出库单号',
    prop: 'slipNo'
  },
  {
    label: '出库日期',
    prop: 'slipDate'
  },
  {
    label: '出库原因',
    prop: 'slipReason'
  },
  {
    label: '指令',
    prop: 'lotNo'
  },
  {
    label: '材料颜色',
    prop: 'mtlColor'
  },
  {
    label: '材料名称',
    prop: 'mtlName'
  },
  {
    label: '规格',
    prop: 'mtlSpec'
  },
  {
    label: '单位',
    prop: 'mtlUnit'
  },
  {
    label: '数量',
    prop: 'qty'
  },
  {
    label: '备注',
    prop: 'remark'
  }
])

const tableHeader5 = ref([
  {
    label: '物料编码',
    prop: 'mtlNo'
  },
  {
    label: '颜色',
    prop: 'mtlColor'
  },
  {
    label: '材料名称',
    prop: 'mtlName'
  },
  {
    label: '规格',
    prop: 'mtlSpec'
  },
  {
    label: '单位',
    prop: 'mtlUnit'
  },
  {
    label: '剩料量',
    prop: 'stkQty'
  }
])

const tableHeader6 = ref([
  {
    label: '指令',
    prop: 'lotNo'
  },
  {
    label: '物料编码',
    prop: 'mtlNo'
  },
  {
    label: '材料颜色',
    prop: 'mtlColor'
  },
  {
    label: '材料名称',
    prop: 'mtlName'
  },
  {
    label: '规格',
    prop: 'mtlSpec'
  },
  {
    label: '单位',
    prop: 'mtlUnit'
  },
  {
    label: '用量',
    prop: 'ttlUsage'
  },
  {
    label: '剩料量',
    prop: 'stkQty'
  }
])

const tableHeader7 = ref([
  {
    label: '物料编码',
    prop: 'mtlNo'
  },
  {
    label: '子材料名称',
    prop: 'mtlName'
  },
  {
    label: '子材料颜色',
    prop: 'mtlColor'
  },
  {
    label: '规格',
    prop: 'mtlSpec'
  },
  {
    label: '单位',
    prop: 'mtlUnit'
  },
  {
    label: '比例',
    prop: 'percent'
  },
  {
    label: '剩料量',
    prop: 'stkQty'
  },
  {
    label: '是否请购',
    prop: 'purFlag',
    type: 'checkbox'
  }
])
</script>

<style lang="less" scoped>
h1 {
  font-size: 16px;
}

.table1 {
  :deep(th:nth-child(6)) {
    color: red !important;
  }

  :deep(th:nth-child(7)) {
    color: red !important;
  }
}
</style>
